// wait_group 实现有条件的等待
#include <workflow/WFFacilities.h>
#include <workflow/WFTaskFactory.h>
#include <workflow/WFHttpServer.h>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>

using std::cout;
using std::cerr;
using std::string;

struct SeriesContext{
    string username;
    string password;
    protocol::HttpResponse *resp;
};

static WFFacilities::WaitGroup waitGroup(1);

void process(WFHttpTask * serverTask){
    cout <<  "process called!\n";

    protocol::HttpRequest *req = serverTask->get_req();
    protocol::HttpResponse *resp = serverTask->get_resp();

    string method = req->get_method();
    string url = req->get_request_uri();
    string path = url.substr(0, url.find("?"));

    SeriesContext *context = new SeriesContext;

}

int main()
{
    signal(SIGINT, nullptr);

    WFHttpServer server(process);
    if(server.start(1234) == 0){
        cout << "server start success!\n";
        waitGroup.wait();
        server.stop();
    }else{
        perror("server start");
        return -1;
    }
    return 0;
}